<?php
require_once "common/Utils.php";
//include_once ('Utils.php');
//print_r(Utils::get_signature());
//$signatureStr = 'jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg&noncestr=Wm3WZYTPz0wzccnW&timestamp=1414587457&url=http://mp.weixin.qq.com?params=value';
//$access_token=Utils::get_access_token();
//$jsapi_ticket=Utils::get_jsapi_ticket($access_token);
//$signature=Utils::get_signature();
//echo $access_token;
//echo '/***************/';
//print_r('/***********************************************/');
//echo  $jsapi_ticket;
//echo '/***************/';
//print_r(Utils::random_int(0,100));
//print_r(base64_encode(hash_hmac("sha1", $signatureStr, '', true)));
//include_once('wxUtils.php');
//$access_token=wxUtils::get_access_token();
//print_r($access_token);
//print_r('/***********************************************/');
//print_r(wxUtils::get_access_token_session());
/*//读取文件下所有文件
 //$hostdir = dirname(__FILE__);
 //$hostdir='resource/music';
 //获取本文件目录的文件夹地址
 //$filesnames = scandir($hostdir);
 //获取也就是扫描文件夹内的文件及文件夹名存入数组 $filesnames
 //print_r ($filesnames);

 //foreach ($filesnames as $name) {	//echo $name;
 //$url = "http://www.****.com//" . $name;
 //$aurl = "<a href=\"" . $url . "\">" . $url . "</a>";
 //$pathinfo=pathinfo($hostdir.'/'.$name);
 //if(!empty($pathinfo['extension'])){
 //print_r("{'Title':$pathinfo[basename],'Description':$pathinfo[basename],'MusicUrl':$hostdir/$name}");
 ///}else{
 //print_r("<br/>");
 //print_r ($pathinfo);
 //}
 //print_r("<br/>");
 //echo $name . "<br/>";
 //}*/
//include_once 'common/config.php';
//include_once 'common/Utils.php';
//Utils::get_music_list();
//Utils::set_music_json(Utils::get_music_list());
//Utils::get_music_json();

//$testJSON=array('name'=>'中文字符串','value'=>'test');
//print_r(json_encode(Utils::get_music_list()));
//print_r(json_decode($testJSON));
//print_r(json_decode(urldecode(file_get_contents("common/music.json"))));
//$content = array();
//$music = json_decode(Utils::get_music_json());//获取歌曲JSON对象数组
//print_r(json_decode($music));
//$content = array($music[rand(0, count($music) - 1)]);//从数组中获取歌曲列表
//print_r(gettype($content));
/*$music = json_decode(Utils::get_music_json());
 //获取歌曲JSON对象数组
 $mItem = $music[rand(0, count($music) - 1)];
 print_r(gettype($mItem));
 print_r("<br/>");
 $mItem=get_object_vars($mItem);
 print_r($mItem);
 //$content = array($music[rand(0, count($music) - 1)]);//从数组中获取歌曲列表
 $content = array("Title" =>urldecode($mItem['Title']), "Description" => urldecode($mItem['Description']), "MusicUrl" => urldecode($mItem['MusicUrl']), "HQMusicUrl" => urldecode($mItem['MusicUrl']));
 print_r($content);*/
/*$str = "车站";
 print_r($str);
 print_r("<br/>");
 print_r(urlencode($str));
 print_r("<br/>");
 print_r("<br/>");
 print_r(urlencode(mb_convert_encoding('车站', 'UTF-8', 'GB2312,gbk,ascii,UTF-8')));
 print_r("<br/>");
 print_r("<br/>");
 print_r("<br/>");
 print_r(rawurlencode(mb_convert_encoding('车站', 'utf-8', 'gbk')));
 print_r("<br/>");
 print_r("<br/>");
 print_r("<br/>");
 print_r(iconv("GB2312", "UTF-8//IGNORE", '车站'));
 print_r("<br/>");
 print_r("<br/>");
 print_r("<br/>");
 $content = array();
 $music = json_decode(Utils::get_music_json());
 print_r($music);
 print_r("<br/>");
 print_r("<br/>");
 print_r("<br/>");
 //获取歌曲JSON对象数组
 $mItem = $music[rand(0, count($music) - 1)];
 $mItem = is_object($mItem) ? get_object_vars($mItem) : $mItem;
 print_r($mItem);*/
/*//$content="Title:$mItem[Title],Description:$mItem[Description],MusicUrl:$mItem[MusicUrl]";
 $content = array("Title" => urldecode($mItem['Title']), "Description" => urldecode($mItem['Description']), "MusicUrl" => urldecode($mItem['MusicUrl']), "HQMusicUrl" => urldecode($mItem['MusicUrl']));
 $cha=mb_detect_encoding($str);
 $s = iconv($cha,"UTF-8",$str);
 print_r($content);*/
/*$str="从数组中获取歌曲列表";
 print_r($str);
 print_r("<br/>");
 $str = urlencode($str);
 print_r($str);
 print_r("<br/>");
 $str = urldecode($str);
 print_r($str);
 print_r("<br/>");
 print_r(mb_convert_encoding($str, 'GB2312', 'UTF-8'));*/
//文件名打印
/*$str = "车站";
 print_r($str);
 print_r("<br/>");
 print_r(urlencode($str));
 print_r("<br/>");
 print_r(urlencode(mb_convert_encoding($str, 'GB2312', 'UTF-8')));
 print_r("<br/>");
 $hostdir = 'resource/music';
 //获取本文件目录的文件夹地址
 $filesnames = scandir('./' . $hostdir);
 $musicArr = array();
 //获取也就是扫描文件夹内的文件及文件夹名存入数组 $filesnames
 foreach ($filesnames as $name) {
 //$pathinfo = pathinfo($hostdir . '/' . $name);
 $pathinfo = Utils::mb_pathinfo($hostdir . '/' . $name);
 if (!empty($pathinfo['extension'])) {
 //文件名统一格式规定：歌曲名_专辑_歌手
 //print_r($pathinfo['filename']);
 //print_r("<br />");
 $musicFileName = explode('_', $pathinfo['filename']);
 $music['oTitle'] = $musicFileName[0];
 $music['Title'] = urlencode(mb_convert_encoding($musicFileName[0],'UTF-8', 'GB2312,gbk,utf-8'));
 //$music['Description'] = urlencode("$musicFileName[1]&#x4E13;&#x8F91;:$musicFileName[2]");
 //$music['MusicUrl'] = urlencode(SERVER_IP . "$hostdir/$name");
 //array_push($musicArr, $music);
 print_r($music);
 print_r("<br />");
 }
 }*/
//date_default_timezone_set('prc');
//print_r(date('y-m-d H:i:s',time()));
//print_r($musicArr);
//$json = '{"workorderid":"0000100609","results":[{"statuscode":1,"coll":[{"collectionid":"31","devcode":"415","dis_value":"0.00","is_red":"0","isnecessary":"1","maxval":"","minval":"","signalid":"0415102001","unit":"℃"}]},{"statuscode":1,"alaram1":[{"devcode":"415","pass":"0","signalid":"0415001001","warningid":"6","win":""},{"devcode":"4184","pass":"1","signalid":"0418001001","warningid":"8","win":"0"},{"devcode":"4182","pass":"0","signalid":"0418002001","warningid":"7","win":""}]},{"statuscode":1,"alaram2":[]},{"statuscode":1,"alaram3":[]},{"statuscode":1,"alaram4":[]},{"statuscode":1,"alaram5":[]},{"statuscode":1,"remote":[{"devcode":"417","pass":"-1","remoteid":"1","signalid":"0417201001"},{"devcode":"415","pass":"","remoteid":"2","signalid":"0415201001"},{"devcode":"415","pass":"-1","remoteid":"3","signalid":"0415202001"}]}]}';
//$array = json_decode($json, true);
//$workorder = $array['workorderid'];
//print_r($array);
//require_once "common/jssdk.php";
//$jssdk = new JSSDK();
//print_r($jssdk ->getAppId());
//$in = 'qunlist';
//$server = "http://pro.mdg-app.com:7001/thinkphp/index.php/Home/QunService/" . $in;
//echo Utils::curl_post($server,null);
//require_once "common/jssdk.php";
//$jssdk = new JSSDK();
//print_r($jssdk -> getAccessToken());
//print_r($jssdk -> createMenu());
require_once "common/MySQLUtils.php";
		 $mysqlu = new MySQLUtils();
		 //已经存在就更新，否则就直接插入数据库
		 //查询数据是否存在
		 $u = $mysqlu -> query("select count(1) from t_user where openid=''");
		 print_r($u);
?>